<?php 
	include("/includes/header.php");
	include("/includes/sidebar.php"); 

	$sql_setting = "SELECT * FROM setting";
	$query_setting = mysql_query($sql_setting);
	$result_setting = mysql_fetch_array($query_setting);
?>

<form class="form-horizontal">
	<div class="content row-fluid"> 
		<div class="span12">
			<div class="alert_container"></div>

    	<div>
    		<div>
    			<div class="alert alert-info">
    				<h4>Setting</h4>
			    </div>
					<div class="control-group">
						<label class="control-label">Number of tables</label>
						<div class="controls">
							<input placeholder="Masukkan Jumlah meja" type="text" name="jumlah_meja" class="jumlah_meja span6 required" data-toggle="tooltip" title="Masukkan Jumlah meja" value="<?php echo $result_setting[jumlah_meja] ?>">
						</div>
					</div>
					<div class="control-group input-append">
						<label class="control-label">Tax (%)</label>
						<div class="controls">
							<input id="appendedInput" placeholder="Masukkan Persentase Pajak (Tax)" type="text" name="tax" class="tax span6 required" data-toggle="tooltip" title="Masukkan Persentase Pajak (Tax)" value="<?php echo $result_setting[tax] ?>">
						</div>
					</div>
					<div class="control-group input-append">
						<label class="control-label">Service (%)</label>
						<div class="controls">
							<input id="appendedInput" placeholder="Masukkan Persentase Service" type="text" name="service" class="service span6 required" data-toggle="tooltip" title="Masukkan Persentase Service" value="<?php echo $result_setting[service] ?>">
						</div>
					</div>
					<div class="control-group input-append">
						<label class="control-label">Credit Card (%)</label>
						<div class="controls">
							<input id="appendedInput" placeholder="Masukkan Persentase Credit Card" type="text" name="credit_card" class="credit_card span6 required" data-toggle="tooltip" title="Masukkan Persentase Credit Card" value="<?php echo $result_setting[credit_card] ?>">
						</div>
					</div>
    		</div>
    	</div>
			<div>
				<div class="span12">
					<ul class="breadcrumb well">
						<button type="submit" class="btn btn-info btn-simpan">
							<i class="fa fa-check"></i>
							Simpan
						</button>
					</ul>
				</div>
			</div>
		</div>
	</div>
</form>

<div class="footer">
</div>

<?php include("/includes/footer.php") ?>       

<SCRIPT TYPE="text/javascript">
	$(document).ready(function() {
		$('.btn-simpan').click(function(event) {
			event.preventDefault();
			if (validate_form()) {
				alert_msg = "Data berhasil diubah";
				
				var tipeUser = {
					jumlah_meja: $('.jumlah_meja').val(),
					tax: $('.tax').val(),
					service: $('.service').val(),
					credit_card: $('.credit_card').val()
				}

				$.ajax({
					url: '/action/act_setting.php',
					type: 'POST',
					data: tipeUser,
					cache: false, 
	        success: function(data){
	        	if (data == "sukses") {
		        	alert(alert_msg);
		        	window.location = "setting.php";
	        	} else {
	        		alert(data);
	        	}
	        }
				})
			}
		});
	});
</SCRIPT>